import { defineStore } from 'pinia'
import { store } from '../index'
import { FormSchema } from '@/components/Form'
import { DescriptionsSchema } from '@/components/Descriptions'
import { TableColumn } from '@/components/Table'
interface setupFromOptionState {
  searchFrom: FormSchema[]
  detailForm: DescriptionsSchema[]
  form: FormSchema[]
  table: TableColumn[]
}
export const useSetupFromOptionStateStore = defineStore('setupForm', {
  state: (): setupFromOptionState => {
    return {
      searchFrom: [],
      detailForm: [],
      form: [],
      table: []
    }
  },
  getters: {
    getSearchForm(): FormSchema[] {
      return this.searchFrom
    },
    getDetailForm(): DescriptionsSchema[] {
      return this.detailForm
    },
    getForm(): FormSchema[] {
      return this.form
    },
    getTable(): TableColumn[] {
      return this.table
    }
  },
  actions: {
    setSearchForm(searchFrom: FormSchema[]) {
      this.searchFrom = searchFrom
    },
    setDetailForm(detailForm: DescriptionsSchema[]) {
      this.detailForm = detailForm
    },
    setForm(form: FormSchema[]) {
      this.form = form
    },
    setTable(table: TableColumn[]) {
      this.table = table
    }
  }
})
export const useSetupFromOptionStoreWithOut = () => {
  return useSetupFromOptionStateStore(store)
}
